#define _CRT_SECURE_NO_WARNINGS 1
#include<iostream>
#include<stdio.h>
#include<windows.h>
using namespace std;
int Square(int n)
{
    return n * n;
}
bool isHappy(int n) {

    int ret = n;
    long long sum = 0;
    while (sum <1000)
    {
        sum = 0;
        int tmp = 0;
        while (ret)
        {
            tmp = ret % 10;
            ret /= 10;
            sum += Square(tmp);
        }
        ret = sum;
        cout << "sum:" << sum << endl;
        Sleep(1);
        if (ret == 1) return true;
    }
    return false;
}
int main()
{
    cout << "is Happy:" << isHappy(2) << endl;
	return 0;
}